package com.itheima.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PluginConfig {
    /**
     * 注册分页插件
     *
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor plusInterceptor = new MybatisPlusInterceptor();
        //创建内置的分页插件对象
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor();
        //设置分页limit不设限制
        innerInterceptor.setMaxLimit(-1L);
        //设置操纵的数据库
        innerInterceptor.setDbType(DbType.MYSQL);
        //注册插件
        plusInterceptor.addInnerInterceptor(innerInterceptor);
        return plusInterceptor;
    }
}
